// Highlight

@import '../../style/themes/default';
@import '../../style/mixins/index';
@import './param';

@mixin highlight {
  display: block;
  line-height: 0;
  width: 100%;
  border: 0.0625rem solid var(--x-border);
  > pre {
    display: flex;
    padding: 0.875rem 0.875rem 0.875rem 3.5rem;
    margin: 0;
    overflow: auto;
    background-color: $--x-background;
    counter-reset: line-number;
    > code {
      position: relative;
      line-height: 1.1875rem;
      text-shadow: none;
      white-space: inherit;
      min-width: 100%;
      color: $--x-text;
      > span.line-numbers {
        position: absolute;
        pointer-events: none;
        top: 0;
        font-size: 100%;
        left: -3.5rem;
        width: 3.5rem;
        letter-spacing: -1px;
        user-select: none;
        color: $--x-text-400;
        > span::before {
          border-right: $--x-border-base;
          padding-right: 0.5rem;
          margin-right: 0.875rem;
          text-align: right;
          pointer-events: none;
          display: block;
          counter-increment: line-number;
          content: counter(line-number);
        }
      }
      > .line-highlight {
        position: absolute;
        opacity: 0.1;
        pointer-events: none;
        line-height: inherit;
        white-space: pre;
        width: calc(100% + 3.5rem);
        left: -3.5rem;
        border-radius: $--x-border-radius;
        @include line-highlight-type(primary, $--x-primary);
        @include line-highlight-type(success, $--x-success);
        @include line-highlight-type(warning, $--x-warning);
        @include line-highlight-type(danger, $--x-danger);
        @include line-highlight-type(info, $--x-info);
      }
    }
  }
  .token.operator,
  .token.entity,
  .token.url,
  .language-css .token.string,
  .style .token.string {
    color: $--x-text;
    background: transparent;
  }
  .token.property,
  .token.tag,
  .token.boolean,
  .token.number,
  .token.constant,
  .token.symbol,
  .token.deleted {
    color: #e6a23c;
  }
}

@mixin line-highlight-type($type, $background-color) {
  &.#{$type} {
    background-color: $background-color;
  }
}
